namespace NHCodeFirst.FluentMapper
{
    using System;
    using HbmModel;

    public class ClassMapperBase<TChild>
    {
        private readonly Class @class;
        protected TChild child;

        internal ClassMapperBase(Class @class)
        {
            this.@class = @class;
        }

        public TChild EntityName(string value)
        {
            @class.EntityName = value;
            return child;
        }

        public TChild Lazy(bool value)
        {
            @class.Lazy = value.ToString().ToLower();
            return child;
        }

        public TChild DiscriminatorValue(object value)
        {
            @class.DiscriminatorValue = value.ToString();
            return child;
        }

        public TChild DynamicInsert(bool value)
        {
            @class.DynamicInsert = value.ToString().ToLower();
            return child;
        }

        public TChild DynamicUpdate(bool value)
        {
            @class.DynamicUpdate = value.ToString().ToLower();
            return child;
        }

        public TChild SelectBeforeUpdate(bool value)
        {
            @class.SelectBeforeUpdate = value.ToString().ToLower();
            return child;
        }

        public TChild Proxy(Type value)
        {
            @class.Proxy = value.FullName;
            return child;
        }

        public TChild Proxy<TProxy>()
        {
            @class.Proxy = typeof (TProxy).FullName;
            return child;
        }

        public TChild Persister<TPersister>()
        {
            @class.Persister = typeof (TPersister).FullName;
            return child;
        }

        public TChild Persister(Type value)
        {
            @class.Persister = value.FullName;
            return child;
        }

        public TChild BatchSize(int value)
        {
            @class.BatchSize = value.ToString();
            return child;
        }
    }
}